module iTimer.ui.Menu;
import iTimer.Types;

final class AppMenus {
	
	static Menu Bar ;
    static Menu Task_Menu ;
	static MenuItem[] Task_Menu_Items ;
	
	static void load(){
		Bar = new Menu (GShell, DWT.BAR);
		GShell.setMenuBar (Bar);

		loadTask();
		
		loadHelp();
	}
	
	
	static void loadTask(){
        
		auto items = new MenuItem (Bar, DWT.CASCADE);
		items.setText ("任务");
		auto submenu = new Menu (GShell, DWT.DROP_DOWN);
		items.setMenu (submenu);
        
        Task_Menu   = submenu ;
		
		auto item0 = new MenuItem (submenu, DWT.PUSH);	
		item0.setText ("添加任务");
		item0.addListener(DWT.Selection, new class Listener{
			public void handleEvent(Event e){
				iTaskList.add_task();
			}
		});
        Task_Menu_Items ~= item0 ;
        
		auto item1 = new MenuItem (submenu, DWT.PUSH);	
		item1.setText ("修改任务");
		item1.addListener(DWT.Selection, new class Listener{
			public void handleEvent(Event e){
				iTaskList.edit_task();
			}
		});
        item1.setEnabled(false);
        Task_Menu_Items ~= item1 ;
        
		auto item2 = new MenuItem (submenu, DWT.PUSH);	
		item2.setText ("删除任务");
		item2.addListener(DWT.Selection, new class Listener{
			public void handleEvent(Event e){
				iTaskList.del_task();
			}
		});
        item2.setEnabled(false);
        Task_Menu_Items ~= item2 ;
    }
	
	static void loadHelp(){
		
		auto items = new MenuItem (Bar, DWT.CASCADE);
		items.setText ("帮助");

		auto submenu = new Menu (GShell, DWT.DROP_DOWN);
		items.setMenu (submenu);
		
		auto item0 = new MenuItem (submenu, DWT.PUSH);	
		item0.setText ("关于我们");
		item0.addListener(DWT.Selection, new class Listener{
			public void handleEvent(Event e){
				MessageBox.showInfo(
					"http://code.google.com/p/gool/", 
					"关于我们",
					GShell);
			}
		});
		
	}

}
